package li.com.springaidemo.common;

import lombok.Data;

@Data
public class R {

    private static final String SUCCESS = "0";
    private static final String ERROR = "-1";

    private String code;
    private String msg;
    private Object data;

    public static R success() {
        R r = new R();
        r.setCode(SUCCESS);
        return r;
    }

    public static R success(Object data) {
        R r = new R();
        r.setCode(SUCCESS);
        r.setData(data);
        return r;
    }

    public static R error(String msg) {
        R r = new R();
        r.setCode(ERROR);
        r.setMsg(msg);
        return r;
    }
    public static R error(String code,String msg) {
        R r = new R();
        r.setCode(code);
        r.setMsg(msg);
        return r;
    }
}
